<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>补充案例1-JS进阶（一）</title>
    </head>
    <body>
        <pre>
            <code>
                    // 补充案例1：请分析以下代码的运行过程
                    setTimeout(function() {
                        console.log('timeout1');
                        new Promise(function(resolve1) {
                            console.log('promise1');
                            resolve1();
                        }).then(function() {
                            console.log('then1')
                        })
                    }, 20)

                    new Promise(function(resolve2) {
                        console.log('promise2');
                        resolve2();
                    }).then(function() {
                        console.log('then2')
                    })

                    setTimeout(function() {
                        console.log('timeout2');
                    }, 10)

                    setTimeout(function() {
                        console.log('timeout3');
                        new Promise(function(resolve3) {
                            console.log('promise3');
                            resolve3();
                        }).then(function() {
                            console.log('then3')
                        })
                    })
                    console.log('global');
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/p_2.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>